/*
 *  SyncIT , easy synchronization of files between computers and devices.
 *  Copyright (C) 2011  Christian Masus <cmasus(at)gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version. If redistributing and/or modifying
 *  this file, this notice must be included in the redistributed or
 *  modified copy.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package start;

import controller.Controller;

/**
 * Starts the SyncIT application. Can take in some arguments at start.
 * @author Christian Masus
 *
 */
public class SyncIT {

	public final String version = "2.0";

	public SyncIT(String[] args) {
		String configPath = "";
		String guiType = "";
		int i = 0;
		try {
			while(i < args.length) {
				if(args[i].equals("-h") || args[i].equals("--help")) {
					printUsage();
				}
				if(args[i].equals("-v") || args[i].equals("--version")) {
					printVersion();
				}
				else if(args[i].equals("-config")) {
					configPath = args[++i];
				}
				else if(args[i].equals("-gui")) {
					guiType = args[++i];
				}
				else {
					printUsage();
				}
				i++;
			}
		}
		catch(Exception e) {
			printUsage();
		}

		new Controller(version, configPath, guiType);
	}


	private void printUsage() {
		System.out.println("Usage: SyncIT [OPTIONS]");
		System.out.println("  -config config_path  Set a configuration path.");
		System.out.println("  -gui {JavaGui, JavaGuiNative, Text, WebGui, ...}");
		System.out.println("                       Set a gui type.");
		System.out.println("  -v  --version        Output version info.");
		System.out.println("  -h  --help           Output this help.");
		System.exit(0); // Terminate execution
	}

	private void printVersion() {
		System.out.println("SyncIT version " + version);
		System.exit(0); // Terminate execution
	}


	public static void main(String[] args) {
		new SyncIT(args);
	}
}


